package format.bigdecimal;

import java.text.DecimalFormat;

/**
 * @author Cheng Jun
 * @version 1.0
 * Description: 通过在迪拜购物中心购物，学习如何使用 DecimalFormat
 * @date 2019/9/9 15:54
 */
public class DubaiShopping {

    //兰博基尼专卖店的存车数量
    private static final int LAMBORGHINI_STOCK = 9_999;
    //黄金专卖店的黄金库存量：单位kg
    private static final double GOLD_STOCK = 100_000_000.00D;
    //钻石专卖店的钻石库存量：单位g
    private static final double DIAMOND_STOCK = 1_230_340.45D;

    public static void main(String[] args) {

        //兰博基尼数量的格式：
        DecimalFormat lamborghiniStockDF = new DecimalFormat();
        //黄金库存量的格式
        DecimalFormat goldStockDF = new DecimalFormat("000000000.00kg");
        //钻石库存量的格式
        DecimalFormat diamondStockDF = new DecimalFormat("0,000,000.000#g");

        System.out.println(lamborghiniStockDF.format(LAMBORGHINI_STOCK));
        System.out.println(goldStockDF.format(GOLD_STOCK));
        System.out.println(diamondStockDF.format(DIAMOND_STOCK));
        System.out.println(Math.round(1.5));

    }
}
